\doxysection{bsp\+\_\+iic.\+h}
\hypertarget{bsp__iic_8h_source}{}\label{bsp__iic_8h_source}\index{C:/Users/ASUS/Desktop/dm-\/ctrlH7-\/balance-\/9025test/bsp/iic/bsp\_iic.h@{C:/Users/ASUS/Desktop/dm-\/ctrlH7-\/balance-\/9025test/bsp/iic/bsp\_iic.h}}

\begin{DoxyCode}{0}
\DoxyCodeLine{00001\ \textcolor{preprocessor}{\#include\ "{}i2c.h"{}}}
\DoxyCodeLine{00002\ \textcolor{preprocessor}{\#include\ "{}stdint.h"{}}}
\DoxyCodeLine{00003\ }
\DoxyCodeLine{00004\ \textcolor{preprocessor}{\#define\ IIC\_DEVICE\_CNT\ 2\ \ \ }\textcolor{comment}{//\ C板引出了I2C2和I2C3}}
\DoxyCodeLine{00005\ \textcolor{preprocessor}{\#define\ MX\_IIC\_SLAVE\_CNT\ 8\ }\textcolor{comment}{//\ 最大从机数目,根据需要修改}}
\DoxyCodeLine{00006\ }
\DoxyCodeLine{00007\ \textcolor{comment}{/*\ i2c\ 工作模式枚举\ */}}
\DoxyCodeLine{00008\ \textcolor{keyword}{typedef}\ \textcolor{keyword}{enum}}
\DoxyCodeLine{00009\ \{}
\DoxyCodeLine{00010\ \ \ \ \ \textcolor{comment}{//\ 基本工作模式}}
\DoxyCodeLine{00011\ \ \ \ \ IIC\_BLOCK\_MODE\ =\ 0,\ \textcolor{comment}{//\ 阻塞模式}}
\DoxyCodeLine{00012\ \ \ \ \ IIC\_IT\_MODE,\ \ \ \ \ \ \ \ \textcolor{comment}{//\ 中断模式}}
\DoxyCodeLine{00013\ \ \ \ \ IIC\_DMA\_MODE,\ \ \ \ \ \ \ \textcolor{comment}{//\ DMA模式}}
\DoxyCodeLine{00014\ }
\DoxyCodeLine{00015\ \}\ IIC\_Work\_Mode\_e;}
\DoxyCodeLine{00016\ }
\DoxyCodeLine{00017\ \textcolor{comment}{/*\ I2C\ MEM工作模式枚举,这两种方法都是阻塞\ */}}
\DoxyCodeLine{00018\ \textcolor{keyword}{typedef}\ \textcolor{keyword}{enum}}
\DoxyCodeLine{00019\ \{}
\DoxyCodeLine{00020\ \ \ \ \ IIC\_READ\_MEM\ =\ 0,\ \textcolor{comment}{//\ 读取从机内部的寄存器or内存}}
\DoxyCodeLine{00021\ \ \ \ \ IIC\_WRITE\_MEM,\ \ \ \ \textcolor{comment}{//\ 写入从机内部的寄存器or内存}}
\DoxyCodeLine{00022\ \}\ IIC\_Mem\_Mode\_e;}
\DoxyCodeLine{00023\ }
\DoxyCodeLine{00024\ \textcolor{comment}{/*\ Seq传输工作模式枚举,注意HOLD\_ON要在IT或DMA下使用\ */}}
\DoxyCodeLine{00025\ \textcolor{comment}{//\ 必须以IIC\_RELEASE为最后一次传输,否则会导致总线占有权无法释放}}
\DoxyCodeLine{00026\ \textcolor{keyword}{typedef}\ \textcolor{keyword}{enum}}
\DoxyCodeLine{00027\ \{}
\DoxyCodeLine{00028\ \ \ \ \ IIC\_SEQ\_RELEASE,\ \ \ \ \textcolor{comment}{//\ 完成传输后释放总线占有权,这是默认的传输方式}}
\DoxyCodeLine{00029\ \ \ \ \ IIC\_SEQ\_HOLDON\ =\ 0,\ \textcolor{comment}{//\ 保持总线占有权不释放,只支持IT和DMA模式}}
\DoxyCodeLine{00030\ \}\ IIC\_Seq\_Mode\_e;}
\DoxyCodeLine{00031\ }
\DoxyCodeLine{00032\ \textcolor{comment}{/*\ i2c实例\ */}}
\DoxyCodeLine{00033\ \textcolor{keyword}{typedef}\ \textcolor{keyword}{struct\ }\mbox{\hyperlink{structiic__temp__s}{iic\_temp\_s}}}
\DoxyCodeLine{00034\ \{}
\DoxyCodeLine{00035\ \ \ \ \ I2C\_HandleTypeDef\ *handle;\ \textcolor{comment}{//\ i2c\ handle}}
\DoxyCodeLine{00036\ \ \ \ \ uint8\_t\ dev\_address;\ \ \ \ \ \ \ \textcolor{comment}{//\ 暂时只支持7位地址(还有一位是读写位)}}
\DoxyCodeLine{00037\ }
\DoxyCodeLine{00038\ \ \ \ \ IIC\_Work\_Mode\_e\ work\_mode;\ \ \ \ \ \ \ \ \ \ \ \ \ \textcolor{comment}{//\ 工作模式}}
\DoxyCodeLine{00039\ \ \ \ \ uint8\_t\ *rx\_buffer;\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \textcolor{comment}{//\ 接收缓冲区指针}}
\DoxyCodeLine{00040\ \ \ \ \ uint8\_t\ rx\_len;\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \textcolor{comment}{//\ 接收长度}}
\DoxyCodeLine{00041\ \ \ \ \ void\ (*callback)(\textcolor{keyword}{struct\ }\mbox{\hyperlink{structiic__temp__s}{iic\_temp\_s}}\ *);\ \textcolor{comment}{//\ 接收完成后的回调函数}}
\DoxyCodeLine{00042\ }
\DoxyCodeLine{00043\ \ \ \ \ \textcolor{keywordtype}{void}\ *id;\ \textcolor{comment}{//\ 用于标识i2c\ instance}}
\DoxyCodeLine{00044\ \}\ IICInstance;}
\DoxyCodeLine{00045\ }
\DoxyCodeLine{00046\ \textcolor{comment}{/*\ I2C\ 初始化结构体配置\ */}}
\DoxyCodeLine{00047\ \textcolor{keyword}{typedef}\ \textcolor{keyword}{struct}}
\DoxyCodeLine{00048\ \{}
\DoxyCodeLine{00049\ \ \ \ \ I2C\_HandleTypeDef\ *handle;\ \ \ \ \ \ \ \textcolor{comment}{//\ i2c\ handle}}
\DoxyCodeLine{00050\ \ \ \ \ uint8\_t\ dev\_address;\ \ \ \ \ \ \ \ \ \ \ \ \ \textcolor{comment}{//\ 暂时只支持7位地址(还有一位是读写位),注意不需要左移}}
\DoxyCodeLine{00051\ \ \ \ \ IIC\_Work\_Mode\_e\ work\_mode;\ \ \ \ \ \ \ \textcolor{comment}{//\ 工作模式}}
\DoxyCodeLine{00052\ \ \ \ \ void\ (*callback)(IICInstance\ *);\ \textcolor{comment}{//\ 接收完成后的回调函数}}
\DoxyCodeLine{00053\ \ \ \ \ \textcolor{keywordtype}{void}\ *id;\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \textcolor{comment}{//\ 用于标识i2c\ instance}}
\DoxyCodeLine{00054\ \}\ \mbox{\hyperlink{struct_i_i_c___init___config__s}{IIC\_Init\_Config\_s}};}
\DoxyCodeLine{00055\ }
\DoxyCodeLine{00062\ IICInstance\ *IICRegister(\mbox{\hyperlink{struct_i_i_c___init___config__s}{IIC\_Init\_Config\_s}}\ *conf);}
\DoxyCodeLine{00063\ }
\DoxyCodeLine{00070\ \textcolor{keywordtype}{void}\ IICSetMode(IICInstance\ *iic,\ IIC\_Work\_Mode\_e\ mode);}
\DoxyCodeLine{00071\ }
\DoxyCodeLine{00082\ \textcolor{keywordtype}{void}\ IICTransmit(IICInstance\ *iic,\ uint8\_t\ *data,\ uint16\_t\ size,\ IIC\_Seq\_Mode\_e\ mode);}
\DoxyCodeLine{00083\ }
\DoxyCodeLine{00094\ \textcolor{keywordtype}{void}\ IICReceive(IICInstance\ *iic,\ uint8\_t\ *data,\ uint16\_t\ size,\ IIC\_Seq\_Mode\_e\ mode);}
\DoxyCodeLine{00095\ }
\DoxyCodeLine{00106\ \textcolor{keywordtype}{void}\ IICAccessMem(IICInstance\ *iic,\ uint16\_t\ mem\_addr,\ uint8\_t\ *data,\ uint16\_t\ size,\ IIC\_Mem\_Mode\_e\ mode,\ uint8\_t\ mem8bit\_flag);}

\end{DoxyCode}
